<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站监控系统</title>
		<link rel="stylesheet" type="text/css" href="./static/admin/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="./static/admin/css/admin.css"/>
            
	    <script type="text/javascript" src="./static/js/jquery-1.12.4.js"></script>
	    <script type="text/javascript" src="./static/js/my.js"></script>

	</head>
	<body>
		<div class="main-layout" id='main-layout'>
			<!--侧边栏-->
			<div class="main-layout-side">
				<div class="m-logo">
				</div>
				<ul class="layui-nav layui-nav-tree" lay-filter="leftNav">

				  <li class="layui-nav-item">
					  <a href="javascript:;" data-url="site-list.html" data-id='30' data-text="网站管理"><span class="l-line"></span><i class="iconfont">&#xe60c;</i>网站管理</a>
				  </li>

				  <li class="layui-nav-item">
				    <a href="javascript:;" data-url="admin-info.html" data-id='5' data-text="个人信息"><i class="iconfont">&#xe606;</i>个人信息</a>
				  </li>

				</ul>
			</div>
			<!--右侧内容-->
			<div class="main-layout-container">
				<!--头部-->
				<div class="main-layout-header">
					<div class="menu-btn" id="hideBtn">
						<a href="javascript:;">
							<span class="iconfont">&#xe60e;</span>
						</a>
					</div>
					<ul class="layui-nav" lay-filter="rightNav">
					  <li class="layui-nav-item"><a href="javascript:;" data-url="email.html" data-id='4' data-text="邮件系统"><i class="iconfont">&#xe603;</i></a></li>
					  <li class="layui-nav-item">
					    <a href="javascript:;" data-url="admin-info.html" data-id='5' id="user_info" data-text="个人信息">超级管理员</a>
					  </li>
					  <li class="layui-nav-item"><a href="javascript:;" id="logout">退出</a></li>
					</ul>
				</div>
				<!--主体内容-->
				<div class="main-layout-body">
					<!--tab 切换-->
					<div class="layui-tab layui-tab-brief main-layout-tab" lay-filter="tab" lay-allowClose="true">
					  <ul class="layui-tab-title">
					    <li class="layui-this welcome">后台主页</li>
					  </ul>
					  <div class="layui-tab-content">
					    <div class="layui-tab-item layui-show" style="background: #f5f5f5;">
					    	<!--1-->
					    	<iframe src="welcome.html" width="100%" height="100%" name="iframe" scrolling="auto" class="iframe" framborder="0"></iframe>
					    	<!--1end-->
					    </div>
					  </div>
					</div>
				</div>
			</div>
			<!--遮罩-->
			<div class="main-mask">
				
			</div>
		</div>
		<script type="text/javascript">
			var scope={
				link:'./welcome.html'
			}
		</script>
		<script src="./static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="./static/admin/js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="./static/admin/js/main.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="./static/js/jquery-1.12.4.js"></script>

		<script>
			check_login();
			function check_login() {
				//确认有没有登录
				$.ajax({
					"url": "/api/user",
					"type": "get",
					"dataType": 'json',
					xhrFields: {
						withCredentials: true
					},
					error: function () {
						console.log("登录获取失败")
					},crossDomain: true,
					success: function (data) {
						if (data.code == 20){
							$('#user_info').html(data.data['email']);
						}else{
							alert("还没登录/登录超时了~");
							window.location.href = '/login.html'
						}
						// if (data.code == 0) {
						//     $('#user').html(data.msg)
						// } else {
						//     alert(data.msg);
						//     window.location.href = 'login.html';
						// }
					}
				})
			}
		</script>
		<script>
			//用户登出事件
			$(function () {
				layui.use('layer', function(){
					var $ = layui.jquery
							,layer = layui.layer //弹层

					//弹出登录页面
					$(document).on('click','#logout',function(){
						//登出
						$.ajax({
							"url": "/api/user/logout",
							"type": "post",
							"dataType": 'json',
							xhrFields: {
								withCredentials: true
							},
							error: function () {
								console.log("登录获取失败")
							},
							success: function (data) {
								if (data.code == 20){
									alert("退出登录，即将转到登录页面");
									window.location.href = '/login.html'
								}else{
									alert(data.msg);
									// window.location.href = '/login.html'
								}
							}
						})
					});

				});

			});

		</script>
	</body>
</html>
